<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$return=array();
if($_RQ['op']=='get'){
	$return['htmls']=array();
	$type=intval($_RQ['type']);
	$typetitle=get_plugin_intypes()[$type];
	$applist=array(
			array('name'=>'jy_weishop','title'=>'智慧电商客','desc'=>'一款大而全的商城平台系统','icon'=>'fa-shopping-cart','action'=>''),
	);
	$applist=pdo_getall('core_plugins',array('style'=>1,'intype'=>$type),array('name','title','description','oneword','image'));
	foreach($applist as &$p){
		$p['desc']=$p['description'];
		$install = check_permission($p['name']);
		if($install){
			$p['is_install'] = 1;
			$p['is_show'] = 1;
		}else{
			$p['is_install'] = 0;
			$p['is_show'] = 0;
			if($_SESSION['isfounder']){
				$p['is_show'] = 1;
			}
		}
		
	}
	$return['htmls']=array(
		array('type'=>'data','tpltype'=>6,'title'=>$typetitle,'datas'=>$applist),
	);
	set_html('title',$typetitle);
	set_html('header','common/header');
	exi($return);
}
if($_RQ['op']=='add_quick'){
	$postdata=get_postdata();
	$data=array(
		'uid'=>$_SESSION['uid'],
		'action'=>trim($postdata['action']),
		'plugin'=>trim($postdata['plugin']),
		'op'=>trim($postdata['op']),
		'query'=>trim($postdata['query']),
		'title'=>trim($postdata['title']),
		'html'=>trim($postdata['html'])
	);
	pdo_insert('core_user_quick',$data);
	$id=pdo_insertid();
	$res=array('id'=>$id,'type'=>'success');
	exi($res);
}
if($_RQ['op']=='set_quick'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=intval($post['id']);
		if(!$id){
			exi('请先设置要保存的快捷方式！','error');
		}
		$update=array_fields(array('title'),$post);
		pdo_update('core_user_quick',$update,array('id'=>$id,'uid'=>$_SESSION['uid']));
		exi('操作成功！');
	}
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择要设置的快捷方式！','error');
	}
	$item=pdo_get('core_user_quick',array('id'=>$id,'uid'=>$_SESSION['uid']),array('id','title'));
	if(!$item){
		exi('要编辑设置的快捷方式不存在！','error');
	}
	$return['item']=$item;
	$return['htmls']=array(
		'type'=>'edit',
		'edit'=>array(
			array('type'=>'string','name'=>'title','title'=>'快捷方式名称'),
		),
	);
	exi($return);
}
if($_RQ['op']=='del'){
	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('core_user_quick',array('id'=>$id,'uid'=>$_SESSION['uid']));
	}
	exi('删除成功！');
}
?>